#include "mywidget.h"
#include "ui_mywidget.h"
#include <QPainter>
//#include <QPushButton>
#include <QDebug>

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MyWidget)
{
    ui->setupUi(this);

    // 点击移动按钮 移动图片
    connect(ui->pushButton, &QPushButton::clicked, [=]() {
        // 手动调用绘图事件, update 函数
        update();
    });



}

MyWidget::~MyWidget()
{
    delete ui;
}

void MyWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    posX += 5;
    painter.drawPixmap(posX, 0, QPixmap(":/Image/dabai.png"));

}

